package com.sugar.MultiThread.a14waitandnotify;

import com.sugar.MultiThread.a13waitandnotify.Desk;

import java.util.concurrent.ArrayBlockingQueue;

public class Cook extends Thread {
    /*
     * 1. 循环
     * 2. 同步代码块
     * 3. 判断共享数据是否到了末尾（到了末尾）
     * 4. 判断共享数据是否到了末尾（没有到末尾，执行核心逻辑）
     * */
    ArrayBlockingQueue<String> queue;


    public Cook(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
            try {
                queue.put("面条");
                System.out.println("厨子做了一碗面条");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
